package org.hadoop.hive;
import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.ResultSet;
import java.sql.Statement;
public class HiveJdbcCount {
    public static void main(String[] args) throws Exception {
        Class.forName("org.apache.hive.jdbc.HiveDriver");
        String url = "jdbc:hive2://server201:10000/one";
        Connection con = DriverManager.getConnection(url,"hadoop","");
        Statement st  = con.createStatement();
        ResultSet rs = st.executeQuery("select count(1) from stud");
        rs.next();
        int anInt = rs.getInt(1);
        System.out.println("统计结果："+anInt);
        rs.close();
        st.close();
        con.close();
    }
}
